/*
*************************************
* PocketGTT
*************************************
This file is part of PocketGTT.

PocketGTT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

PocketGTT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with PocketGTT.  If not, see <http://www.gnu.org/licenses/>.
*/

import QtQuick 1.0

Item {
    id: btnQuitReload

    width: myWin.width/2;
    height: parent.height

    anchors.right: parent.right
    anchors.bottom: parent.bottom
    anchors.verticalCenter: parent.verticalCenter

    property color pressedColor: myWin.theme.blue_background

    Rectangle {
        anchors.centerIn: parent
        height: parent.height * 0.9
        width: parent.height  * 0.9
        color: btnMA.pressed ? parent.pressedColor : "transparent"
        radius: width / 4

        Image {
            id: btnImgQuit
            fillMode: Image.PreserveAspectFit
            height: parent.height * 0.8
            anchors.centerIn: parent
            source: "qrc:ui/close_stop.svg"
        }
    }

    MouseArea {
        id: btnMA
        anchors.fill: parent
        onClicked: {
            if (myWin.statesMan.pageViewStatus == 1) {  //GTTStopInfo.resultsPage
//                myWin.statesMan.fermata.LoadComplete()
                GTT.reloadStop();

            }
            else {  //GTTStopInfo.searchPage
                GTT.pocketGTTquit();
            }
        }
    }

    states: [
        State {
            name: "quit"
            when: !GTT.SelectMultipleStopsStatus && !myWin.statesMan.pageViewStatus
            PropertyChanges { target: btnImgQuit; source: "qrc:ui/close_stop.svg"}
            PropertyChanges { target: btnQuitReload; pressedColor: myWin.theme.blue_background}
        },
        State {
            name: "quitFromMultiPref"
            when: GTT.SelectMultipleStopsStatus && !myWin.statesMan.pageViewStatus
            PropertyChanges { target: btnImgQuit; source: "qrc:ui/close_stop.svg"}
            PropertyChanges { target: btnQuitReload; pressedColor: myWin.theme.green_background}
        },
        State {
            name: "refreshFromPassaggi"
            when: myWin.statesMan.pageViewStatus == 1 //GTTStopInfo.resultsPage
            PropertyChanges { target: btnImgQuit; source: "qrc:ui/refresh.svg"}
            PropertyChanges { target: btnQuitReload; pressedColor: myWin.theme.violet_background}
        }

    ]

}
